﻿using System;
using System.Text;
using IAM.Interface.Model.ENUM;
using System.Web;
using System.Xml;
using IAM.Interface.Model;

namespace IAM.Interface.Common.Providers
{
    /// <summary>
    /// xml传送管理类
    /// </summary>
    public class ProviderMgnt
    {
        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tranpar">传送参数</param>
        /// <param name="xml">xml信息包</param>
        public ProviderMgnt(TransmissionParameter tranpar, string xml)
        {
            _tranpar = tranpar;
            _xml = xml;
        }
        #endregion
        #region 属性
        private string _xml = "";
        private TransmissionParameter _tranpar = null;

        /// <summary>
        /// 目的地址
        /// </summary>
        public virtual string URL
        {
            get
            {
               return  _tranpar.URL;
            }
        }
        /// <summary>
        /// xml信息
        /// </summary>
        public virtual string XML
        {
            get
            {
                return _xml;
            }
            set
            {
                _xml = value;
            }
        }

        #endregion
        #region 创建一个接口传对象
        /// <summary>
        /// 创建一个接口传对象
        /// </summary>
        /// <returns></returns>
        public IProvider CreateProvider()
        {
            IProvider obj = null;

            switch (_tranpar.ProviderEnum)
            {
                case ProviderEnum.Http:
                    obj = new HttpProvider(URL, XML);
                    break;
                case ProviderEnum.Local:
                    obj = new LocalProvider(URL, XML);
                    break;
                case ProviderEnum.SAP:
                    obj = new SAPProvider(URL, XML);
                    break;
            }
            return obj;
        }
        #endregion
    }
}
